package com.fnzx.service.impl;

import com.fnzx.dao.ExpertDao;
import com.fnzx.entity.ExpertEntity;
import com.fnzx.service.ExpertService;
import com.fnzx.util.PageUtils;
import com.fnzx.util.Query;
import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;


@Service("expertService")
public class ExpertServiceImpl extends ServiceImpl<ExpertDao, ExpertEntity> implements ExpertService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<ExpertEntity> page = this.page(
                new Query<ExpertEntity>().getPage(params,"sort_value",false),
                new QueryWrapper<ExpertEntity>()
        );

        return new PageUtils(page);
    }
    @Override
    public PageUtils queryPageByTitle(Map<String, Object> params) {
        QueryWrapper<ExpertEntity> queryWrapper = new QueryWrapper<ExpertEntity>();
        if (params.get("name") != null && params.get("name") != "") {
            queryWrapper.like("name",params.get("name"));
        }
        IPage<ExpertEntity> page = this.page(
                new Query<ExpertEntity>().getPage(params),
                queryWrapper
        );
        return new PageUtils(page);
    }

}